package com.cheil.publish.config;

import com.cheil.publish.service.ai.DashscopeImageModel;
import com.cheil.publish.service.ai.DashscopeImageOptions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.retry.policy.SimpleRetryPolicy;
import org.springframework.retry.support.RetryTemplate;

/**
 * Dashscope图像模型配置类
 */
@Configuration
public class DashscopeImageConfiguration {
    
    @Value("${spring.ai.dashscope.api-key}")
    private String apiKey;
    
    @Bean
    public DashscopeImageModel dashscopeImageModel() {
        DashscopeImageOptions options = DashscopeImageOptions.builder()
                .model("wan2.2-t2i-flash")
                .n(1)
                .size("1024*1024")
                .build();
        RetryTemplate retryTemplate = new RetryTemplate();
        retryTemplate.setRetryPolicy(
                new SimpleRetryPolicy(1)
        );
        return new DashscopeImageModel(apiKey, options, retryTemplate);
    }
}